glarea: Flip our texture
authorMatthias Clasen <mclasen@redhat.com>
Sun, 27 Sep 2020 16:33:13 +0000 (12:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 28 Sep 2020 15:34:23 +0000 (11:34 -0400)
The texture that produce is upside-down, compared to what
GSK expects, so flip things around with a transform.

This fixes the shadertoy demo being upside-down after a
recent fix to avoid downloading and reuploading the texture.

gtk/gtkglarea.c

index 4cb815e1d91fb7d699a3f4a40b0f3d34332e9169..3387a36ca2010311ad3519cb918c1f108503164e 100644 (file)
@@ -744,11 +744,18 @@ gtk_gl_area_snapshot (GtkWidget   *widget,
                                             texture->height,
                                             release_texture, texture);
 
+      /* Our texture is rendered by OpenGL, so it is upside down,
+       * compared to what GSK expects, so flip it back.
+       */
+      gtk_snapshot_save (snapshot);
+      gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (0, gtk_widget_get_height (widget)));
+      gtk_snapshot_scale (snapshot, 1, -1);
       gtk_snapshot_append_texture (snapshot,
                                    texture->holder,
                                    &GRAPHENE_RECT_INIT (0, 0,
                                                         gtk_widget_get_width (widget),
                                                         gtk_widget_get_height (widget)));
+      gtk_snapshot_restore (snapshot);
 
       g_object_unref (texture->holder);
     }